package com.richest.api.utils;

import com.richest.api.controller.form.OrderForm;
import com.richest.api.controller.form.OrderSubBanquetForm;
import com.richest.api.controller.form.OrderSubCommodityForm;
import com.richest.api.controller.form.OrderSubForm;
import com.richest.bean.OrderMasterBean;
import com.richest.bean.OrderSubBanquetBean;
import com.richest.bean.OrderSubBean;
import com.richest.bean.OrderSubCommodityBean;

/**
 * 订单表单转换工具
 * 
 * @author 杨博
 *
 */
public class OrderFormConvertUtil {
	/**
	 * 把OrderForm 转换为 OrderMasterBean
	 * 
	 * @param orderForm
	 * @return OrderMasterBean
	 */
	public static OrderMasterBean toOrderMasterBean(OrderForm orderForm) {
		OrderMasterBean bean = new OrderMasterBean();
		bean.setUser_id(orderForm.getUser_id());
		bean.setMerchant_id(orderForm.getMerchant_id());
		bean.setCommit_date_time(orderForm.getCommit_date_time());
		bean.setRemarks(orderForm.getRemarks());
		return bean;
	}

	/**
	 * 把OrderSubForm 转换为 OrderSubBean
	 * 
	 * @param orderSubForm
	 * @param orderMasterId
	 * @return
	 */
	public static OrderSubBean toOrderSubBean(OrderSubForm orderSubForm) {
		if (orderSubForm == null) {
			return null;
		} else {
			OrderSubBean bean = new OrderSubBean();
			bean.setCommit_date_time(orderSubForm.getCommit_date_time());
			bean.setRemarks(orderSubForm.getRemarks());
			bean.setAmount(orderSubForm.getAmount());
			bean.setPayment_amount(orderSubForm.getPayment_amount());
			bean.setDiscount(orderSubForm.getDiscount());
			return bean;
		}
	}

	public static OrderSubBanquetBean toOrderSubBanquetBean(OrderSubBanquetForm orderSubBanquetForm) {
		if (orderSubBanquetForm == null) {
			return null;
		} else {

			OrderSubBanquetBean bean = new OrderSubBanquetBean();
			bean.setBanquet_id(orderSubBanquetForm.getBanquet_id());
			bean.setIs_return(orderSubBanquetForm.getIs_return());
			bean.setService_fee(orderSubBanquetForm.getService_fee());
			bean.setMinimum(orderSubBanquetForm.getMinimum());
			return bean;
		}
	}

	public static OrderSubCommodityBean toOrderSubCommodityBean(OrderSubCommodityForm orderSubCommodityForm) {
		if (orderSubCommodityForm == null) {
			return null;
		} else {
			OrderSubCommodityBean bean = new OrderSubCommodityBean();
			bean.setBanquet_id(orderSubCommodityForm.getBanquet_id());
			bean.setCommodity_id(orderSubCommodityForm.getCommodity_id());
			bean.setCommodity_number(orderSubCommodityForm.getCommodity_number());
			bean.setIs_full_reduction(orderSubCommodityForm.getIs_full_reduction());
			bean.setIs_return(orderSubCommodityForm.getIs_return());
			bean.setIs_spedal_offer(orderSubCommodityForm.getIs_spedal_offer());
			bean.setPrice(orderSubCommodityForm.getPrice());
			return bean;
		}
	}
}
